package com.aia.prm.web.ria.app.ui.file;

import java.io.ByteArrayOutputStream;
import java.io.OutputStream;

import com.vaadin.ui.Upload.Receiver;

@SuppressWarnings("serial")
public class MyReceiver implements Receiver {

	private String fileName;
	private String mtype;
	ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();

	public void clean() {
		byteArrayOutputStream = new ByteArrayOutputStream();
	}

	public ByteArrayOutputStream getByteArrayOutputStream() {
		return byteArrayOutputStream;
	}

	public byte[] toByteArray() {
		return byteArrayOutputStream.toByteArray();
	}

	public OutputStream receiveUpload(String afilename, String amimetype) {
		fileName = afilename;
		mtype = amimetype;
		return byteArrayOutputStream;
	}

	public String getFileName() {
		return fileName;
	}

	public String getMimeType() {
		return mtype;
	}

}
